package com.edou.base.wrapper;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;

/**
 * request包装类
 * @creator     admin
 * @create-time 2017年8月7日   下午2:43:08
 * @email admin@edou.com
 * @company www.edou.com
 * @version 1.0
 */
public class TocerRequestWrapper extends HttpServletRequestWrapper{

	public TocerRequestWrapper(HttpServletRequest request) {
		super(request);
	}

	/**
	 * 重写获取请求参数方法
	 */
	@Override
	public String[] getParameterValues(String name) {
		//获取请求参数
		String[] results = super.getParameterValues(name);
		if(null == results || results.length == 0) {
			return null;
		}
		
		//构造新的数组
		int count = results.length;
		String[] trimResults = new String[count];
		for (int i = 0; i < count; i++) {
			trimResults[i] = results[i].trim();
		}
		
		return trimResults;
	}
}
